home *** CD-ROM | disk | FTP | other *** search
-
-
-
- DBM C Library Procedures DBM
-
-
-
- NNAAMMEE
- dbminit, fetch, store, delete, firstkey, nextkey - data base
- subroutines
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ddbbmm..hh>>
-
- ttyyppeeddeeff ssttrruucctt {{
- cchhaarr **ddppttrr;;
- iinntt ddssiizzee;;
- }} ddaattuumm;;
-
- ddbbmmiinniitt((ffiillee))
- cchhaarr **ffiillee;;
-
- ddaattuumm ffeettcchh((kkeeyy))
- ddaattuumm kkeeyy;;
-
- ssttoorree((kkeeyy,, ccoonntteenntt))
- ddaattuumm kkeeyy,, ccoonntteenntt;;
-
- ddeelleettee((kkeeyy))
- ddaattuumm kkeeyy;;
-
- ddaattuumm ffiirrssttkkeeyy(())
-
- ddaattuumm nneexxttkkeeyy((kkeeyy))
- ddaattuumm kkeeyy;;
-
- DDEESSCCRRIIPPTTIIOONN
- NNoottee:: tthhee ddbbmm lliibbrraarryy hhaass bbeeeenn ssuuppeerrcceeddeedd bbyy nnddbbmm((33)),, aanndd iiss
- nnooww iimmpplleemmeenntteedd uussiinngg nnddbbmm.. These functions maintain
- key/content pairs in a data base. The functions will handle
- very large (a billion blocks) databases and will access a
- keyed item in one or two file system accesses. The func-
- tions are obtained with the loader option --llddbbmm.
-
- _K_e_ys and _c_o_n_t_e_n_ts are described by the _d_a_t_u_m typedef. A
- _d_a_t_u_m specifies a string of _d_s_i_z_e bytes pointed to by _d_p_t_r.
- Arbitrary binary data, as well as normal ASCII strings, are
- allowed. The data base is stored in two files. One file is
- a directory containing a bit map and has `.dir' as its suf-
- fix. The second file contains all data and has `.pag' as
- its suffix.
-
- Before a database can be accessed, it must be opened by
- _d_b_m_i_n_i_t. At the time of this call, the files _f_i_l_e..ddiirr and
- _f_i_l_e..ppaagg must exist. (An empty database is created by
- creating zero-length `.dir' and `.pag' files.)
-
- Once open, the data stored under a key is accessed by _f_e_t_c_h
- and data is placed under a key by _s_t_o_r_e. A key (and its
-
-
-
- Sprite v1.0 May 12, 1986 1
-
-
-
-
-
-
- DBM C Library Procedures DBM
-
-
-
- associated contents) is deleted by _d_e_l_e_t_e. A linear pass
- through all keys in a database may be made, in an
- (apparently) random order, by use of _f_i_r_s_t_k_e_y and _n_e_x_t_k_e_y.
- _F_i_r_s_t_k_e_y will return the first key in the database. With
- any key _n_e_x_t_k_e_y will return the next key in the database.
- This code will traverse the data base:
-
- ffoorr (key = firstkey(); key.dptr != NULL; key =
- nextkey(key))
-
- DDIIAAGGNNOOSSTTIICCSS
- All functions that return an _i_n_t indicate errors with nega-
- tive values. A zero return indicates ok. Routines that
- return a _d_a_t_u_m indicate errors with a null (0) _d_p_t_r.
-
- SSEEEE AALLSSOO
- ndbm(3)
-
- BBUUGGSS
- The `.pag' file will contain holes so that its apparent size
- is about four times its actual content. Older UNIX systems
- may create real file blocks for these holes when touched.
- These files cannot be copied by normal means (cp, cat, tp,
- tar, ar) without filling in the holes.
-
- _D_p_t_r pointers returned by these subroutines point into
- static storage that is changed by subsequent calls.
-
- The sum of the sizes of a key/content pair must not exceed
- the internal block size (currently 1024 bytes). Moreover
- all key/content pairs that hash together must fit on a sin-
- gle block. _S_t_o_r_e will return an error in the event that a
- disk block fills with inseparable data.
-
- _D_e_l_e_t_e does not physically reclaim file space, although it
- does make it available for reuse.
-
- The order of keys presented by _f_i_r_s_t_k_e_y and _n_e_x_t_k_e_y depends
- on a hashing function, not on anything interesting.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Sprite v1.0 May 12, 1986 2
-
-
-
-